//
//  MatePeopleRequstTableViewCell.m
//  TQY
//
//  Created by 甘世清 on 2024/10/3.
//

#import "MatePeopleRequstTableViewCell.h"

@implementation MatePeopleRequstTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self.contentView.backgroundColor = SQColorF1F1F1;
    
    UIView * bgView = [[UIView alloc]init];
    bgView.layer.cornerRadius = 10;
    bgView.layer.masksToBounds = YES;
    bgView.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(10, 12, 0, 12));
    }];

    [self.contentView addSubview:self.headerView];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(50);
            make.left.equalTo(self.contentView).offset(24);
            make.top.equalTo(self.contentView).offset(24);
    }];
    [self.contentView addSubview:self.genderImage];
    [self.genderImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(12);
            make.bottom.left.equalTo(self.headerView);
    }];
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerView.mas_right).offset(10);
        make.top.equalTo(self.headerView).offset(10);
    }];
    [self.contentView addSubview:self.messageLabel];
    [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerView.mas_right).offset(10);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-24);
    }];
    UIView * lineView = [[UIView alloc]init];
    lineView.backgroundColor = SQColorF5F5F5;
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(bgView);
            make.top.equalTo(self.messageLabel.mas_bottom).offset(10);
            make.height.mas_equalTo(1);
    }];

    [bgView addSubview:self.addBtn];
    [self.addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(bgView.mas_right).offset(-32);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(40);
        make.top.equalTo(lineView.mas_bottom).offset(10);
    }];
 
    [bgView addSubview:self.jujueBtn];
    [self.jujueBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgView).offset(32);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(40);
        make.top.equalTo(lineView.mas_bottom).offset(10);
    }];
 
    self.FS_cellBottomView = self.addBtn;
  
}
- (void)setModel:(MateModel *)model{
    _model = model;
    [self.headerView.headerImage sd_setImageWithURL:SQURLImage(model.portrait) placeholderImage:SQGetImage(@"1")];
    self.nameLabel.text = model.name;
    self.messageLabel.text =  model.content;
    
    if ([model.gender isEqualToString:@"2"]) {
        self.genderImage.image = SQGetImage(@"女");
    } else {
        self.genderImage.image = SQGetImage(@"男");
    }
}

-(void)SQ_headerViewButtonClick{
    PeopleDetailViewController * vc = [[PeopleDetailViewController alloc]init];
    vc.uid = self.model.uid;
    [[Manager SQ_getCurrentViewController].navigationController pushViewController:vc animated:YES];
}
- (UILabel *)messageLabel{
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc]init];
        _messageLabel.font = FONT_REGULAR(14);
        _messageLabel.textColor = UIColor.blackColor;
        _messageLabel.backgroundColor = UIColor.clearColor;
        _messageLabel.numberOfLines = 0;
    }
    return _messageLabel;
}
 
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(16);
        _nameLabel.textColor = UIColor.blackColor;
        _nameLabel.backgroundColor = UIColor.clearColor;
        _nameLabel.numberOfLines = 0;
    }
    return _nameLabel;
}

- (HeaderView *)headerView{
    if (!_headerView) {
        _headerView = [[HeaderView alloc]init];
        _headerView.headerImage.contentMode = UIViewContentModeScaleAspectFill;
        _headerView.clipsToBounds = YES;
        [_headerView.btn addTarget:self action:@selector(SQ_headerViewButtonClick) forControlEvents:UIControlEventTouchUpInside];
        _headerView.layer.cornerRadius = 25;
        _headerView.layer.masksToBounds = YES;
    }
    return _headerView;
}
- (SQCustomButton *)jujueBtn{
    if (!_jujueBtn) {
        _jujueBtn = [[SQCustomButton alloc]initType:SQCustomButtonLeftImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _jujueBtn.text = SQNSLocalString(@"拒绝");
        _jujueBtn.font = FONT_REGULAR(14);
        _jujueBtn.backgroundColor = SQHexColor(@"#999999", 0.5);
        _jujueBtn.textColor = UIColor.whiteColor;
        _jujueBtn.layer.cornerRadius = 10;
        _jujueBtn.layer.masksToBounds = YES;
    }
    return _jujueBtn;
}

- (SQCustomButton *)addBtn{
    if (!_addBtn) {
        _addBtn = [[SQCustomButton alloc]initType:SQCustomButtonLeftImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _addBtn.text = SQNSLocalString(@"接受");
        _addBtn.font = FONT_REGULAR(14);
        _addBtn.backgroundColor = SQColor3DA59D;
        _addBtn.textColor = UIColor.whiteColor;
        _addBtn.layer.cornerRadius = 10;
        _addBtn.layer.masksToBounds = YES;
    }
    return _addBtn;
}

- (UIImageView *)genderImage{
    if (!_genderImage) {
        _genderImage = [[UIImageView alloc]init];
        _genderImage.image = SQGetImage(@"女");
    }
    return _genderImage;
}
 
@end
